/**
 * 
 */
package com.dovgopoly.carlogbook.common.mvp;

import com.google.gwt.user.client.ui.Widget;

/**
 * <code>View</code> is an interface of a view implementation (from MVP triplet)
 * that is exposed to the respective presenter. Every concrete view interface
 * should inherit <code>View</code>. Generic type <code>P</code> represents a
 * concrete interface (extended from <code>Presenter</code>) that is implemented
 * by the respective presenter and that a view implementation uses to notify the
 * presenter of view events.
 * 
 * In order to express logical bounding bound between <code>View</code> and
 * <code>Presenter</code> the former could be defined as an inner interface as
 * follows: <br/>
 * <br/>
 * <code>
 * public interface AConcreteView extends View&lt;AConcreteView.Presenter&gt; {<br/>
 *   <br/>
 *   public interface Presenter extends com.telegraaf.relatieplanet.bo.client.common.Presenter {<br/>
 *   	...
 *   	<br/>
 *   }<br/>
 *   ...
 *   <br/>
 * }<br/>
 * </code> <br/>
 * 
 * @see Presenter
 */
public interface IView<P extends IPresenter> {

	/**
	 * A setter used to inject a reference to the presenter into the view
	 * implementation.
	 * 
	 * @param presenter
	 *            a concrete presenter interface
	 */
	public void setPresenter(P presenter);

	/**
	 * A getter that returns the reference to the presenter.
	 * 
	 * @return the reference to the presenter
	 */
	public P getPresenter();

	/**
	 * Returns a reference to a <code>Widget</code> that contains the view
	 * implementation. Usually it is <code>this</code> reference of the view
	 * implementation itself.
	 * 
	 * @return the view containing <code>Widget</code>
	 */
	public Widget asWidget();

	/**
	 * Shows error message, which was received when performing some operations
	 * in presenter.
	 * 
	 * @param errorMessage
	 *            Error message
	 */
	public void showErrorMessage(String errorMessage);

	/**
	 * Shows warning message, which was received when performing some operations
	 * in presenter.
	 * 
	 * @param title
	 * @param warningMessage
	 *            Warning message
	 */
	public void showWarningMessage(String title, String warningMessage);

}
